<!DOCTYPE html>
<html lang="zh-ch">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="shortcut icon" href="favicon.ico">
    <title>lu_zizhirenzheng</title>
    <link href="ADMIN_PUBLIC/css/bootstrap.min.css" rel="stylesheet">
    <link href="ADMIN_PUBLIC/css/animate.min.css" rel="stylesheet">
    <link href="ADMIN_PUBLIC/css/style.min.css" rel="stylesheet">
    <link rel="stylesheet" href="ADMIN_PUBLIC/fonts_style/iconfont.css">
    <link rel="stylesheet" type="text/css" href="ADMIN_PUBLIC/css/lu_common.css">
    <link rel="stylesheet" type="text/css" href="ADMIN_PUBLIC/css/lu_zizhirenzhegn.css">
    <style>
        a.btn:hover{
            color:#fff;
        }
        div.progress{
            /*text-align:center;*/
            /*display:none;*/
            opacity:0;
            background-color:#ccc;
            border-radius:16px;
            position:relative;
            height:10px;
            width:100px;
            text-align:center;
            margin:0 auto;
        }
        div.progress.active{
            /*display:block;*/
            opacity:1;
        }
        div.progress>div{
            width:0%;
            height:10px;
            background-color:#1577E4;
            border-radius:16px;
            position:absolute;
            left:0;
            top:0;
            bottom:0;
            text-align:center;
        }

        #error{
            display:none
        }
        #error.active{
            width:300px;
            min-height:100px;
            display:block;
            position: fixed;
            top:5%;
            left:0;
            right:0;
            z-index: 101;
            margin:auto;
            background-color: #ffffff;
            color: #ff0000;
            border: 1px solid #999999;
            border-radius: 8px;
            padding: 20px;
            text-align:center;
        }
        #error>p{
            text-align:center;
        }
        #error>button{
            width:60px;
            height:30px;
            font-size:14px;
        }
    </style>
</head>
<body class="color_fff">
<div class="will " id="will">
    <p>请进行企业认证</p>
    <ul>
        <li class="list">
            <p>
                <i class="iconfont icon-qc-required"></i>
                <span>企业名称：</span>
            </p>
            <div>
                <input type="text" class="input_style" id='com_name' autocomplete="off">
            </div>
        </li>
        <li class="list_top">
            <p>
                <i class="iconfont icon-qc-required"></i>
                <span>营业执照：</span>
            </p>
            <div class="file_boxs">
                <div class="file_box">
                    <img src="ADMIN_PUBLIC/img/upload.png" alt="" width="100" height="100">
                    <input type="file" id='files' accept="image/jpeg,image/png">
                    <div class='progress'>
                        <div></div>
                    </div>
                </div>
                <p>请上传加盖公章的营业执照复印件(图片,大小不超过2MB)</p>
            </div>
        </li>
        <li class="list">
            <p>
                <i class="iconfont icon-qc-required"></i>
                <span>法人姓名：</span>
            </p>
            <div>
                <input type="text" class="input_style" id='ceo' autocomplete="off">
            </div>
        </li>
        <li class="list">
            <p>
                <i class="iconfont icon-qc-required"></i>
                <span>法人身份证：</span>
            </p>
            <div>
                <input type="text" class="input_style" id='ceo_code' autocomplete="off">
            </div>
        </li>
        <li class="list">
            <p>
                <i class="iconfont icon-qc-required"></i>
                <span>科技型中小企业编号：</span>
            </p>
            <div>
                <input type="text" class="input_style" id='zhengshu_num' autocomplete="off">
            </div>
        </li>
        <li class="list_top">
            <p>
                <i class="iconfont icon-qc-required"></i>
                <span>证明材料：</span>
            </p>
            <div class="file_boxs">
                <div class="file_box">
                    <img src="ADMIN_PUBLIC/img/upload.png" alt="" width="100" height="100">
                    <input type="file" id='zhengshu_files' accept="image/jpeg,image/png">
                    <div class='progress'>
                        <div></div>
                    </div>
                </div>
                <p>请上传科技型中小企业证书(图片,大小不超过2MB)</p>
            </div>
        </li>
        <li>
            <a class="btn" style='display:inline-block;line-height: 60px; padding: 0;'>立即认证</a>
        </li>
    </ul>
</div>
<div class="ing " id="ing">
    <img src="ADMIN_PUBLIC/img/shenhe_ing.png" alt="" width="180" height="180">
    <p>企业认证正在审核中，请耐心等待！</p>
</div>
<div class=" animated fadeIn" id='file'>
    <!--<img src="img/shenhe_file.png" alt="" width="100" height="100">-->
    <p>企业认证审核失败，请重新认证！</p>
</div>
<div class='animated fadeIn' id='error'>
    <p>该公司已被注册！</p>
    <button class='btn btn-sm btn-success'>确认</button>
</div>
<script src="ADMIN_PUBLIC/js/jquery.min.js"></script>
<script>
$(function(){
    //进来先判断状态
    $.ajax({
        url:'http://zsjjkc.youledi.cn/Admin/ComInfo/getStatus',
        type:'get',
        success:function(data){
            if(data.code==1){
                let status = data.lcom_status
                if(status==0){
                    $('#will').addClass('active')
                }else if(status==1){
                    $('#ing').addClass('active')
                }else if(status==2){
                    $('#file').addClass('active')
                    tipShow()
                    $('#will').addClass('active')
                }
            }
        }
    })

    // 上传文件
    $('#files').on('change',function(){
        let data = this.files;
        let that = this
        for(let i =0;i<data.length;i++){
            let fileReader = new FileReader();
            fileReader.readAsDataURL(data[i]);
            fileReader.onload = function (e){
                let url = this.result;//上传文件的URL
                $(that).siblings('img').attr('src',url)
                $(that).siblings('.progress').addClass('active')
                let n = 0
//                $(that).siblings('.progress').children('div').css({'width':n+'%'})
                let progressBar = setInterval(function(){
                    n+=5
                    $(that).siblings('.progress').children('div').css({'width':n+'%'})
                    if(n>85){
                        clearTimeout(progressBar)
                    }
                },150)
                $.ajax({
                    url:'http://zsjjkc.youledi.cn/Admin/ComInfo/uploadBuss',
                    type:'post',
                    data:{
                        buss:url
                    },
                    success:function(data){
                        if(data.code==1){
                            $(that).siblings('.progress').children('div').css({'width':'100%'})
                            clearTimeout(progressBar)
                            $(that).siblings('.progress').attr('upload','true')
                        }else{
                            $('#file>p').html(data.msg)
                            $('#file').addClass('active')
                            tipShow()
                        }
                    }

                })
            }

        }
    })

    $('#zhengshu_files').on('change',function(){
        let data = this.files;
        let that = this
        for(let i =0;i<data.length;i++){
            let fileReader = new FileReader();
            fileReader.readAsDataURL(data[i]);
            fileReader.onload = function (e){
                let url = this.result;//上传文件的URL
                $(that).siblings('img').attr('src',url)
                $(that).siblings('.progress').addClass('active')
                let n = 0
                $(that).siblings('.progress').children('div').css({'width':n+'%'})
                let progressBar = setInterval(function(){
                    n+=5
                    $(that).siblings('.progress').children('div').css({'width':n+'%'})
                    if(n>85){
                        clearTimeout(progressBar)
                    }
                },150)
                $.ajax({
                    url:'http://zsjjkc.youledi.cn/Admin/ComInfo/HNTechCAImg',
                    type:'post',
                    data:{
                        hcom_img:url,
                        type:2
                    },
                    success:function(data){
//                        console.log('hhhh')
                        if(data.code==1){
                            $(that).siblings('.progress').children('div').css({'width':'100%'})
                            clearTimeout(progressBar)
                            $(that).siblings('.progress').attr('upload','true')
                        }else{
                            $('#zhengshu_files>p').html(data.msg)
                            $('#zhengshu_files').addClass('active')
                            tipShow()
                        }
                    }

                })
            }

        }
    })

    //立即认证
    $('#will .btn').click(function(e){
        e.preventDefault();
        //防止重复点击按钮
        if( $(this).attr('lock') ) return
        

        let com_name = $('#com_name').val()
        let buss = $('#files').siblings('img').attr('src')
        let files = $('#files').val()
        let ceo = $('#ceo').val()
        let ceo_code = $('#ceo_code').val()
        let zhengshu_num = $('#zhengshu_num').val()
        let zhengshu_src = $('#zhengshu_files').siblings('img').attr('src')
        let zhengshu_files = $('#zhengshu_files').val()
        let that = this

        
        if(!com_name){
            $('#com_name').focus()
            $('#com_name').css({'border-color':'#ff0000'})
            $('#com_name').val('')
            $('#com_name').attr('placeholder','不能为空！')
            return
        }else{
            $('#com_name').css({'border-color':'#BFBFBF'})
        } 

        if(!files){
            $('#file>p').html('请上传营业执照！')
            $('#file').addClass('active')
            tipShow()
            return
        }

        if(!ceo){
            $('#ceo').focus()
            $('#ceo').css({'border-color':'#ff0000'})
            $('#ceo').val('')
            $('#ceo').attr('placeholder','不能为空！')
            return
        }else{
            $('#ceo').css({'border-color':'#BFBFBF'})
        }

        if(!ceo_code){
            $('#ceo_code').focus()
            $('#ceo_code').css({'border-color':'#ff0000'})
            $('#ceo_code').val('')
            $('#ceo_code').attr('placeholder','不能为空！')
            return
        }else{
            $('#ceo_code').css({'border-color':'#BFBFBF'})
        }
        let reg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
        if(regCheck(ceo_code,reg)==false){
            $('#ceo_code').focus()
            $('#ceo_code').css({'border-color':'#ff0000'})
            $('#ceo_code').val('')
            $('#ceo_code').attr('placeholder','格式错误！')
            return
        }

        if(!zhengshu_num){
            $('#zhengshu_num').focus()
            $('#zhengshu_num').css({'border-color':'#ff0000'})
            $('#zhengshu_num').val('')
            $('#zhengshu_num').attr('placeholder','不能为空！')
            return
        }else{
            $('#zhengshu_num').css({'border-color':'#BFBFBF'})
        }

        if(!zhengshu_files){
            $('#zhengshu_files>p').html('请上传证明材料！')
            $('#zhengshu_files').addClass('active')
            tipShow()
            return
        }

        if(!$('#files').siblings('.progress').attr('upload')){
            $('#file>p').html('营业执照正在上传，请等待！')
            $('#file').addClass('active')
            tipShow()
            return
        }

        if(!$('#zhengshu_files').siblings('.progress').attr('upload')){
            $('#zhengshu_files>p').html('证明材料正在上传，请等待！')
            $('#zhengshu_files').addClass('active')
            tipShow()
            return
        }
        
        $(this).attr('lock','lock')
        $.ajax({
            url:'http://zsjjkc.youledi.cn/Admin/ComInfo/check',
            type:'post',
            data:{
                com_name:com_name,
                ceo:ceo,
                ceo_code:ceo_code,
                lcom_num:zhengshu_num
            },
            success:function(data){
                if(data.code==1){
                    $('#will').removeClass('active')
                    $('#ing').addClass('active')
                }else{
                    $('#error').children('p').html(data.msg)
                    $('#error').addClass('active')
                }
                $(that).removeAttr('lock')
            }
        })
    })

    $('#error').on('click','button',function(e){
        e.preventDefault();
        $('#error').removeClass('active')
    })

    // 弹出来的小框框
    function tipShow(){
        let tipBox = setTimeout(function(){
            $('#file').removeClass('active')
            clearTimeout(tipBox)
        },3000)
    }

    //正则
    function regCheck(string,reg){
        if(reg.test(string)){
            return true
        }
        return false
    }

})
    
</script>
</body>
</html>